home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume90
/
comm
/
dnet
/
dnet_213
/
part02
< prev
next >
Wrap
Internet Message Format
|
1990-03-27
|
66KB
Path: xanth!cs.odu.edu!Amiga-Request
From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
Newsgroups: comp.sources.amiga
Subject: v90i119: DNet 2.13 - multiple windows/file transfers over a serial line, Part02/08
Message-ID: <11939@xanth.cs.odu.edu>
Date: 27 Mar 90 01:17:51 GMT
Sender: tadguy@cs.odu.edu
Reply-To: dales%teksce.sce.tek.com@RELAY.CS.NET
Lines: 2868
Approved: tadguy@cs.odu.edu (Tad Guy)
X-Mail-Submissions-To: Amiga@cs.odu.edu
X-Post-Discussions-To: comp.sys.amiga
Submitted-by: dales%teksce.sce.tek.com@RELAY.CS.NET
Posting-number: Volume 90, Issue 119
Archive-name: comm/dnet/dnet-2.13/part02
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 8)."
# Contents: amiga/REQUIREMENTS amiga/dnet/channel.h
# amiga/dnet/dataconv.c amiga/dnet/globals.c amiga/dnet/time.c
# amiga/doc/fterm.doc amiga/doc/getfiles.doc amiga/lib/dnetlib.h
# amiga/lib/dnread.c amiga/lib/dwrite.c amiga/s/dnet.config
# amiga/server/scli.c amiga/server/snfs.h amiga/server/spasswd.c
# amiga/server/sprint.c unix/client/draw.c unix/client/dsoc.c
# unix/dnet/channel.h unix/dnet/dataconv.c unix/dnet/double.c
# unix/dnet/files.c unix/dnet/net.c unix/server/scopy.c
# unix/server/sloadav.c unix/server/snfs.h unix/server/sshell.c
# Wrapped by tadguy@xanth on Mon Mar 26 20:14:30 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'amiga/REQUIREMENTS' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/REQUIREMENTS'\"
else
echo shar: Extracting \"'amiga/REQUIREMENTS'\" \(2154 characters\)
sed "s/^X//" >'amiga/REQUIREMENTS' <<'END_OF_FILE'
X
X DNET (c)Copyright 1987-1989 Matthew Dillon, All Rights Reserved
X
X Matthew Dillon
X 891 Regal Rd
X Berkeley, Ca. 94708
X USA
X
X ...!ihnp4!ucbvax!dillon USENET
X dillon@ucbvax.Berkeley.edu ARPANET
X ucbvax.berkeley.edu pub/amiga ARPANET-FTP
X
X CHANGES THIS VERSION:
X 7 bit support
X
X files compile under Lattice C (and don't compile under Aztec C but
X will eventually compiler under the new Aztec).
X
X
X REQUIREMENTS TO RUN DNET ON AN AMIGA
X (This distribution contains the necessary files for running dnet)
X
X ENV: must exist. DNet creates and references ENV: variables
X
X DPIPE: Required only if you intend to run remote CLIs
X (SCLI needs it). A proper Mountlist entry must be
X added and l:dpipe-handler must be installed.
X
X DEVS:SERIAL.DEVICE MUST be the 1.3 serial.device (from your 1.3
X workbench disk) for reliable operation.
X S:DNET.SERVERS must exist and must contain proper paths to
X the various servers.
X S:DNET.CONFIG must exist
X <dnet binaries> All the DNet binaries must be in your path
X
X * read the README file for installation instructions
X
X * files available via USMail or ARPANet FTP to ucbvax.berkeley.edu,
X in the pub/amiga directory as dnet.amiga.bin.tar.Z
X
X FTP/ARPANET ACCESS
X
X ucbvax.berkeley.edu, anonymous login, directory pub/amiga
X
X
X REQUIREMENTS TO COMPILE DNET FOR AN AMIGA
X (This distribution does not contain all files required for compiling)
X
X NOTE: SOURCE / MAKEFILES ARE FOR LATTICE C
X NOTE: the source directory structure must be maintained
X as is. You MUST modify the DMakefile's in the
X source directories to fix the paths to your needs.
X
X Restore -My backup/restore program ... only needed if DNet
X is packaged in a .bak file to unpack it.
X DMake -My make program
X List -Amiga OS V1.3 C:List (on the 1.3 workbench disk)
X sup32.lib -My support library
X local/*.h -#include's for my support library
X
X <dnet-amiga-source> -Source to all the clients, servers, and protocol
X driver.
X
X <dnet-amiga-source> is available via USMail or ARPANet FTP. ARPANET
X
X FTP: ucbvax.berkeley.edu, anonymous login, pub/amiga directory
X
X
END_OF_FILE
if test 2154 -ne `wc -c <'amiga/REQUIREMENTS'`; then
echo shar: \"'amiga/REQUIREMENTS'\" unpacked with wrong size!
fi
# end of 'amiga/REQUIREMENTS'
fi
if test -f 'amiga/dnet/channel.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/channel.h'\"
else
echo shar: Extracting \"'amiga/dnet/channel.h'\" \(1728 characters\)
sed "s/^X//" >'amiga/dnet/channel.h' <<'END_OF_FILE'
X
X/*
X * CHANNEL.H
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * Channel structures for SCMD_* channel commands.
X */
X
X#ifndef DNET_CHANNEL_H
X#define DNET_CHANNEL_H
X
X#ifndef DNET_H
Xtypedef struct IOStdReq IOSTD;
X#endif
X
X#define CSWITCH struct _CSWITCH
X#define COPEN struct _COPEN
X#define CCLOSE struct _CCLOSE
X#define CACKCMD struct _CACKCMD
X#define CEOFCMD struct _CEOFCMD
X#define CIOCTL struct _CIOCTL
X
XCSWITCH { /* SWITCH current data channel */
X ubyte chanh;
X ubyte chanl;
X};
X
XCOPEN { /* OPEN port on channel */
X ubyte chanh;
X ubyte chanl;
X ubyte porth;
X ubyte portl;
X ubyte error; /* error return 0=ok */
X ubyte pri;
X};
X
XCCLOSE { /* CLOSE a channel */
X ubyte chanh;
X ubyte chanl;
X};
X
XCACKCMD { /* Acknowledge an open/close */
X ubyte chanh;
X ubyte chanl;
X ubyte error; /* ERETRY ENOPORT ECLOSE1 ECLOSE2 */
X ubyte filler;
X};
X
XCEOFCMD { /* Send [R/W] EOF */
X ubyte chanh;
X ubyte chanl;
X ubyte flags;
X ubyte filler;
X};
X
XCIOCTL {
X ubyte chanh; /* channel */
X ubyte chanl;
X ubyte cmd; /* ioctl command */
X ubyte valh; /* ioctl value */
X ubyte vall;
X ubyte valaux; /* auxillary field */
X};
X
X#define CIO_SETROWS 1 /* PTY's only */
X#define CIO_SETCOLS 2 /* PTY's only */
X#define CIO_STOP 3 /* any channel, flow control */
X#define CIO_START 4 /* any channel, flow control */
X#define CIO_FLUSH 5
X#define CIO_MODE 6 /* b0=txlate13->10 b1=localecho b2=LF=CRLF */
X
X#define CHAN struct _CHAN
X
XCHAN {
X PORT *port;
X IOSTD *ior;
X ubyte state;
X ubyte flags;
X char pri; /* transmit priority */
X};
X
X#endif
END_OF_FILE
if test 1728 -ne `wc -c <'amiga/dnet/channel.h'`; then
echo shar: \"'amiga/dnet/channel.h'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/channel.h'
fi
if test -f 'amiga/dnet/dataconv.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/dataconv.c'\"
else
echo shar: Extracting \"'amiga/dnet/dataconv.c'\" \(2064 characters\)
sed "s/^X//" >'amiga/dnet/dataconv.c' <<'END_OF_FILE'
X
X/*
X * DATACONV.C
X *
X * Data Conversion.
X */
X
Xtypedef unsigned char ubyte;
Xtypedef unsigned short uword;
Xtypedef unsigned long ulong;
X
X
Xint
XCompress7(s, db, n)
Xubyte *s;
Xubyte *db;
Xuword n; /* actual source bytes */
X{
X ubyte *d = db;
X
X while (n) {
X *d++ = *s++ << 1;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 6;
X *d++ = *s++ << 2;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 5;
X *d++ = *s++ << 3;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 4;
X *d++ = *s++ << 4;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 3;
X *d++ = *s++ << 5;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 2;
X *d++ = *s++ << 6;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 1;
X *d++ = *s++ << 7;
X
X if (--n == 0)
X break;
X d[-1] |= *s++;
X --n;
X }
X return(d - db);
X}
X
Xvoid
XUnCompress7(s, d, n)
Xubyte *s;
Xubyte *d;
Xuword n; /* actual destination bytes */
X{
X while (n) {
X *d++ = s[0] >> 1;
X
X if (--n == 0)
X break;
X *d++ = ((s[0] << 6) | (s[1] >> 2)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[1] << 5) | (s[2] >> 3)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[2] << 4) | (s[3] >> 4)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[3] << 3) | (s[4] >> 5)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[4] << 2) | (s[5] >> 6)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[5] << 1) | (s[6] >> 7)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = s[6] & 0x7F;
X
X --n;
X s += 7;
X }
X}
X
X
Xint
XExpand6(s, db, n)
Xubyte *s;
Xubyte *db;
Xuword n; /* actual source bytes */
X{
X ubyte *d = db;
X
X while (n) {
X *d++ = 0x40 | (*s >> 2);
X *d++ = 0x40 | ((*s++ & 3) << 4);
X if (--n) {
X d[-1] |= *s >> 4;
X *d++ = 0x40 | ((*s++ & 0x0F) << 2);
X if (--n) {
X d[-1] |= *s >> 6;
X *d++ = 0x40 | (*s++ & 0x3F);
X --n;
X }
X }
X }
X return(d - db);
X}
X
Xvoid
XUnExpand6(s, d, n)
Xubyte *s;
Xubyte *d;
Xuword n; /* actual destination bytes */
X{
X while (n) {
X *d++ = (s[0] << 2) | ((s[1] & 0x30) >> 4);
X if (--n == 0)
X break;
X *d++ = (s[1] << 4) | ((s[2] & 0x3C) >> 2);
X if (--n == 0)
X break;
X *d++ = (s[2] << 6) | (s[3] & 0x3F);
X --n;
X s += 4;
X }
X}
X
X
X
END_OF_FILE
if test 2064 -ne `wc -c <'amiga/dnet/dataconv.c'`; then
echo shar: \"'amiga/dnet/dataconv.c'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/dataconv.c'
fi
if test -f 'amiga/dnet/globals.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/globals.c'\"
else
echo shar: Extracting \"'amiga/dnet/globals.c'\" \(1871 characters\)
sed "s/^X//" >'amiga/dnet/globals.c' <<'END_OF_FILE'
X
X/*
X * GLOBALS.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * -restart/packet protocol
X * -dnet->amiga (DNET.READ)
X * -amiga->dnet (DNET.WRITE)
X */
X
X#include "dnet.h"
X
Xint Enable_Abort;
X
XIOT Rto; /* Read-Timeout/reset */
XIOT Wto; /* Write-Timeout/retry */
XIOT Cto; /* 1 second CD check / idle line*/
XPKT Pkts[9]; /* data buffers for packets */
XPKT *RPak[4] = { Pkts+0,Pkts+1,Pkts+2,Pkts+3 };
XPKT *WPak[4] = { Pkts+4,Pkts+5,Pkts+6,Pkts+7 };
XPORT *DNetPort; /* Remote Command/Control in */
XPORT *IOSink; /* Return port for ALL IO */
XPORT *IPCPort; /* IPC software control port */
XCHAN Chan[MAXCHAN]; /* Channels */
XLIST TxList; /* For pending DNCMD_WRITE reqs. */
X
Xubyte Rto_act;
Xubyte Wto_act;
Xubyte Cto_act;
Xubyte Cd; /* Carrier Detect Status */
Xubyte Mode7 = 1;
Xuword WChan; /* Read and Write channels */
Xuword RChan;
Xuword RPStart;
Xuword WPStart;
Xuword WPUsed;
Xuword RState;
Xuword Protocol= -1; /* 0=none 1=xonxoff 2=7wire */
Xuword Parity = -1; /* 0=none 1=odd 2=even 3=mark 4=space */
Xshort DDebug;
Xshort PDebug;
Xubyte Restart; /* Network restart mode */
Xubyte OnLine; /* Network online */
Xubyte Quit; /* Quit immediately */
Xshort AutoAnswer = 0; /* Security Enable */
Xshort DialOut = 1; /* Security Enable for DialOut */
Xshort AutoHangup = 0; /* On carrier lost (-a opt) */
Xshort Master8;
Xshort NetworkNum;
Xshort Getty; /* begun from a getty */
Xulong NumCon; /* # of connections currently active */
X /* in CHAN_ROPEN/LOPEN/OPEN/CLOSE */
Xulong WTimeoutVal;
Xulong RTimeoutVal;
Xlong Baud;
Xlong TOBaud;
Xchar *HostName = "";
X
X/*
X * Status Info
X */
X
Xlong BytesOut, PacketsOut, PacketsResent;
Xlong BytesIn , PacketsIn , PacketsNakd;
Xlong Packets6In, Packets7In, Packets8In;
Xlong Packets6Out, Packets7Out, Packets8Out;
Xlong GarbageIn;
X
END_OF_FILE
if test 1871 -ne `wc -c <'amiga/dnet/globals.c'`; then
echo shar: \"'amiga/dnet/globals.c'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/globals.c'
fi
if test -f 'amiga/dnet/time.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/dnet/time.c'\"
else
echo shar: Extracting \"'amiga/dnet/time.c'\" \(2127 characters\)
sed "s/^X//" >'amiga/dnet/time.c' <<'END_OF_FILE'
X
X/*
X * TIME.C
X *
X * Handle IPC alert functions & timekeeping for connect and idle time.
X */
X
X#include "dnet.h"
X#include <stdio.h>
X#include <local/ipc.h>
X
X#define TICKSIZE 10 /* 10 second intervals */
X
Xstatic long TickIdle;
Xstatic long TickConnect;
X
Xstatic long AlertIdle;
Xstatic long AlertConnect;
X
Xstatic char AIWho[64]; /* app-name to alert */
Xstatic char ACWho[64]; /* app-name to alert */
X
X/*
X * CTO: Idle timeout (check carrier)
X *
X */
X
Xvoid
Xdo_cto(ior)
XIOT *ior;
X{
X if (Cto_act) {
X AbortIO((IOR *)ior);
X WaitIO((IOR *)ior);
X }
X ior->tr_time.tv_secs = TICKSIZE;
X ior->tr_time.tv_micro = 0;
X SendIO((IOR *)ior);
X Cto_act = 1;
X if (Cd) {
X ++TickConnect;
X ++TickIdle;
X }
X if (DDebug)
X printf("I/C: %ld %ld (%ld %ld)\n", TickIdle, TickConnect, AlertIdle, AlertConnect);
X#ifdef NOTDEF
X if (AlertConnect && TickConnect > AlertConnect) /* alert ipc msg */
X doipcmsg(ACWho, "\0connalert", 11);
X if (AlertIdle && TickIdle > AlertIdle) /* alert ipc msg */
X doipcmsg(AIWho, "\0idlealert", 11);
X#endif
X}
X
X/*
X * Idle/Connect time & alerter vars. IPC:
X * resetidle
X * alertidle <N> (N in seconds)
X * alertconn <N> (N in seconds)
X */
X
Xvoid
XResetIdle()
X{
X TickIdle = 0;
X}
X
Xvoid
XResetConnect()
X{
X TickConnect = 0;
X}
X
Xvoid
XLessConnect(n)
X{
X TickConnect -= n;
X if (TickConnect < 0)
X TickConnect = 0;
X}
X
Xvoid
XSetConnectAlert(n, who)
Xchar *who;
X{
X AlertConnect = (n+(TICKSIZE-1))/TICKSIZE;
X ACWho[0] = 0;
X if (who)
X strcpy(ACWho, who);
X}
X
Xvoid
XSetIdleAlert(n, who)
Xchar *who;
X{
X AlertIdle = (n+(TICKSIZE-1))/TICKSIZE;
X AIWho[0] = 0;
X if (who)
X strcpy(AIWho, who);
X}
X
XGetIdle()
X{
X return(TickIdle * TICKSIZE);
X}
X
XGetConnect()
X{
X return(TickConnect * TICKSIZE);
X}
X
X#ifdef NOTDEF
X
Xdoipcmsg(app, cmd, len)
Xchar *app;
Xchar *cmd;
Xshort len;
X{
X IPCMSG *msg;
X long res = 1;
X IPCMSG *SendIPC();
X
X if (DDebug)
X printf("IPC: <%s><%s> = ", app, cmd+1);
X fflush(stdout);
X if (msg = SendIPC(app, cmd, len, 0)) {
X WaitMsg(msg);
X res = msg->Error;
X FreeIPC(msg);
X }
X if (DDebug)
X printf("%ld\n", res);
X}
X
X#endif
END_OF_FILE
if test 2127 -ne `wc -c <'amiga/dnet/time.c'`; then
echo shar: \"'amiga/dnet/time.c'\" unpacked with wrong size!
fi
# end of 'amiga/dnet/time.c'
fi
if test -f 'amiga/doc/fterm.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/doc/fterm.doc'\"
else
echo shar: Extracting \"'amiga/doc/fterm.doc'\" \(1784 characters\)
sed "s/^X//" >'amiga/doc/fterm.doc' <<'END_OF_FILE'
X
XAMIGA/FTERM
XAMIGA/BBSTERM
X
X FTERM [-Nnet] [port#] [-c#] [-wcapturefile]
X
X FTERM opens a standard intuition window and connects to a CSH running on
X the remote UNIX machine. If the remote machine is another Amiga, it
X connects to the terminal-window server (STERM).
X
X UNIX: The csh runs on a PTY and is NOT named, which means you don't show
X up in WHO or FINGER, and cannot TALK other people (nor can they talk you).
X To get a named shell, you must 'rlogin localhost'. This adds another process
X to the character-loop.
X
X The default port# is 8195. You can also specify another port # to
X connect to.
X
X The -N option specifies the network (default = 0). This is the same
X network as was specified when you ran DNET (if was not specified, is 0)
X
X The -c# option (-c7 for example) sets the 'cooked' mode. Bits are
X defined as follows:
X
X bit
X 0 turn keyboard CR's into LFs when sent to remote
X 1 Local Echo (half duplex)
X 2 cause received LFs to generate a CR+LF (i.e. CSI20h)
X
X -wcapturefile Specify name of capture file, else "ram:capture".
X
X Menus: (partially implemented): Capture -capture into ram:capture
X
X Paste -pastes from ram:paste
X
X Flush -get rid of buffered data
X on remote end (that would
X otherwise take a long time
X to display)
X
X BBSTERM is simply FTERM renamed, and uses PORT_BBS (8200) instead of
X PORT_IALPHATERM (8195).
X
X RELEASE INFO:
X
X V1.10 DNET 1.10 release
X
X -Implements auto window resize and auto-remote-resize
X -Implements local echo (cooked mode) and buffering
X
X Remote STERM implements equivalent options and now has the
X same resize/echo/remote-resize capabilities as FTERM.
X
X V1.00 Initial Release
X
X
END_OF_FILE
if test 1784 -ne `wc -c <'amiga/doc/fterm.doc'`; then
echo shar: \"'amiga/doc/fterm.doc'\" unpacked with wrong size!
fi
# end of 'amiga/doc/fterm.doc'
fi
if test -f 'amiga/doc/getfiles.doc' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/doc/getfiles.doc'\"
else
echo shar: Extracting \"'amiga/doc/getfiles.doc'\" \(1624 characters\)
sed "s/^X//" >'amiga/doc/getfiles.doc' <<'END_OF_FILE'
XUNIX/GETFILES
XAMIGA/GETFILES
X
X GETFILES [-Nnet#] [-dlocaldir] [-c] file/dir file/dir file/dir ..
X
X GetFiles file transfer client. Download the specified files and or
X dirs from the remote machine into the current directory, or the
X directory specified if the -d option is used. Entire directory
X trees may be downloaded
X
X The -c "continue" option only downloads files which do not already
X exist. For files which do exist, if the local file size is less
X than the remote file size, the remainder will be downloaded and
X appended to the local file.
X
X SECURITY
X
X The remote host, if an amiga, will impose security restrictions on
X those files allowed to be downloaded according to the comment field
X of said files or any parent directory and the current DNET_READ
X accesslevel.
X
X If the remote AMIGA's DNET_READ enviroment variable is set 9 or
X higher, no access restrictions are imposed.
X
X If the remote AMIGA's DNET_READ enviroment variable is less than
X 9, the comment field of the requested file or the comment field
X of any parent directory to that file (checked all the way to the
X root directory if necessary) must contain a field:
X
X AC=<n>
X
X where <n> is a value less than or equal to the security level
X (DNET_READ enviroment variable). For example, if the remote user
X sets the DNET_READ enviroment variable to 5 (normally done by
X modifying the s:dnet.config file), and then sets the comment field
X for his GAMES: volume to AC=5, remote users who connect to his
X amiga will only be allowed to download files from that volume.
X
X The comment field will be used to house other parameters in the
X future.
X
END_OF_FILE
if test 1624 -ne `wc -c <'amiga/doc/getfiles.doc'`; then
echo shar: \"'amiga/doc/getfiles.doc'\" unpacked with wrong size!
fi
# end of 'amiga/doc/getfiles.doc'
fi
if test -f 'amiga/lib/dnetlib.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/lib/dnetlib.h'\"
else
echo shar: Extracting \"'amiga/lib/dnetlib.h'\" \(2125 characters\)
sed "s/^X//" >'amiga/lib/dnetlib.h' <<'END_OF_FILE'
X
X/*
X * DNETLIB.H
X */
X
X#include "/version.h"
X
X#define CHANN struct _CHANN
X
X#define NAMELEN sizeof("DNET.PORT.XXXXX")
X#define NAMEPAT "DNET.PORT.%ld"
X
XCHANN {
X PORT port; /* receive data, replies */
X PORT *dnetport; /* dnet's master port */
X LIST rdylist; /* ready to be read */
X uword chan; /* channel # for open channels */
X ubyte eof; /* channel remotely closed/eof */
X ubyte filler;
X int qlen; /* allowed write queue size */
X int queued; /* current # packets queued */
X};
X
X#define EFATAL 0
X#define EWARN 1
X#define EDEBUG 2
X
X#define NT_REQUEUE 0x40
X
X#define elog(how, ctl, data) _elog(__LINE__,__FILE__,how,ctl,data)
X
Xextern char *Program;
X
X/*
X * Routines
X */
X
Xextern void Version ARGS((char *, char *, char *));
Xextern PORT *DListen ARGS((uword));
Xextern void DUnListen ARGS((PORT *));
Xextern PORT *DAccept ARGS((PORT *));
Xextern int DNAAccept ARGS((PORT *));
Xextern void DPri ARGS((void *, int));
Xextern PORT *DOpen ARGS((char *, uword, int, int));
Xextern int DCheckEof ARGS((void *));
Xextern short DGetIoctl ARGS((void *, short *, char *));
Xextern long DNRead ARGS((void *, void *, long));
Xextern long DRead ARGS((void *, void *, long));
Xextern void DQueue ARGS((void *, long));
Xextern long DWrite ARGS((void *, void *, long));
Xextern void DEof ARGS((void *));
Xextern void DIoctl ARGS((void *, ubyte, uword, ubyte));
Xextern int DStat ARGS((char *, APTR, long));
Xextern int DQuit ARGS((char *));
Xextern void DClose ARGS((void *));
Xextern int DExec ARGS((void *, char *));
Xextern short WaitQueue ARGS((void *, IOSTD *));
X
Xextern void *MakeChannel ARGS((IOSTD *, char *));
Xextern void DeleteChannel ARGS((void *));
Xextern void FixSignal ARGS((void *));
Xextern int GetEnvVal ARGS((char *));
Xextern int OpenCfgFile ARGS((void));
Xextern char *GetCfgLine ARGS((char *));
Xextern void CloseCfgFile ARGS((void));
Xextern void GetOneCfg ARGS((char *));
Xextern int ExtractFieldVal ARGS((char *, char *, short *));
X
Xextern void _elog ARGS((int, char *, int, char *, void *));
X
END_OF_FILE
if test 2125 -ne `wc -c <'amiga/lib/dnetlib.h'`; then
echo shar: \"'amiga/lib/dnetlib.h'\" unpacked with wrong size!
fi
# end of 'amiga/lib/dnetlib.h'
fi
if test -f 'amiga/lib/dnread.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/lib/dnread.c'\"
else
echo shar: Extracting \"'amiga/lib/dnread.c'\" \(2137 characters\)
sed "s/^X//" >'amiga/lib/dnread.c' <<'END_OF_FILE'
X
X/*
X * DNRead.C
X */
X
X#include "lib.h"
X
Xlong
XDNRead(_chan, _buf, bytes)
Xvoid *_chan;
Xvoid *_buf;
Xlong bytes;
X{
X CHANN *chan = (CHANN *)_chan;
X char *buf = (char *)_buf;
X IOSTD *ior;
X int len = 0;
X long n;
X
X if (chan->eof)
X return(-1);
X while (bytes && ((ior = (IOSTD *)RemHead(&chan->rdylist)) || (ior = (IOSTD *)GetMsg(&chan->port)))) {
X#ifdef DEBUG
X printf("IOR %08lx cmd %d len %d act %d\n", ior, ior->io_Command, ior->io_Length, ior->io_Actual);
X#endif
X if (ior->io_Message.mn_Node.ln_Type == NT_REPLYMSG) {
X if (!chan->queued)
X#ifdef DEBUG
X puts("DNRead: Software Error");
X#else
X ;
X#endif
X else
X --chan->queued;
X if (ior->io_Length)
X FreeMem(ior->io_Data, ior->io_Length);
X FreeMem(ior, sizeof(IOSTD));
X continue;
X }
X switch(ior->io_Command) {
X case DNCMD_CLOSE:
X case DNCMD_EOF:
X chan->eof = 1;
X ReplyMsg((MSG *)ior);
X break;
X case DNCMD_IOCTL:
X if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
X AddHead(&chan->rdylist, (NODE *)ior);
X else
X AddTail(&chan->rdylist, (NODE *)ior);
X ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
X if (len == 0)
X len = -2;
X goto done;
X case DNCMD_WRITE:
X#ifdef DEBUG
X printf("IOR LEN/ACT %ld/%ld\n", ior->io_Length, ior->io_Actual);
X#endif
X n = ior->io_Length - ior->io_Actual;
X#ifdef DEBUG
X if (n < 0)
X puts("len fail");
X#endif
X if (n <= bytes) {
X BMov((char *)ior->io_Data + ior->io_Actual, buf, n);
X bytes -= n;
X len += n;
X buf += n;
X ReplyMsg((MSG *)ior);
X } else {
X BMov((char *)ior->io_Data + ior->io_Actual, buf, bytes);
X len += bytes;
X ior->io_Actual += bytes;
X bytes = 0;
X if (ior->io_Message.mn_Node.ln_Type == NT_REQUEUE)
X AddHead(&chan->rdylist, (NODE *)ior);
X else
X AddTail(&chan->rdylist, (NODE *)ior);
X ior->io_Message.mn_Node.ln_Type = NT_REQUEUE;
X }
X break;
X default:
X ior->io_Error = 1;
X ReplyMsg((MSG *)ior);
X }
X }
X#ifdef DEBUG
X puts("DONE1");
X#endif
Xdone:
X FixSignal(chan);
X if (chan->eof)
X SetSignal(1 << chan->port.mp_SigBit, 1 << chan->port.mp_SigBit);
X#ifdef DEBUG
X printf("RETURN %ld\n", len);
X#endif
X return(len);
X}
X
END_OF_FILE
if test 2137 -ne `wc -c <'amiga/lib/dnread.c'`; then
echo shar: \"'amiga/lib/dnread.c'\" unpacked with wrong size!
fi
# end of 'amiga/lib/dnread.c'
fi
if test -f 'amiga/lib/dwrite.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/lib/dwrite.c'\"
else
echo shar: Extracting \"'amiga/lib/dwrite.c'\" \(1177 characters\)
sed "s/^X//" >'amiga/lib/dwrite.c' <<'END_OF_FILE'
X
X/*
X * DWrite.c
X */
X
X#include "lib.h"
X
Xlong
XDQueueFull(_chan)
Xvoid *_chan;
X{
X CHANN *chan = (CHANN *)_chan;
X
X return (chan->qlen && (chan->queued > chan->qlen));
X}
X
Xlong
XDWrite(_chan, _buf, bytes)
Xvoid *_chan;
Xvoid *_buf;
Xlong bytes;
X{
X int error = bytes;
X CHANN *chan = (CHANN *)_chan;
X char *buf = (char *)_buf;
X
X if (chan->qlen) {
X if (WaitQueue(chan, NULL) >= 0) {
X IOSTD *ior = AllocMem(sizeof(IOSTD), MEMF_CLEAR|MEMF_PUBLIC);
X ior->io_Command = DNCMD_WRITE;
X ior->io_Unit = (void *)chan->chan;
X ior->io_Offset = (long)chan;
X ior->io_Message.mn_ReplyPort = (PORT *)chan;
X ior->io_Data = AllocMem(bytes, MEMF_PUBLIC);
X ior->io_Length = bytes;
X BMov(buf, ior->io_Data, bytes);
X PutMsg(chan->dnetport, (MSG *)ior);
X ++chan->queued;
X } else {
X error = -1;
X }
X } else {
X IOSTD ior;
X ior.io_Command = DNCMD_WRITE;
X ior.io_Unit = (void *)chan->chan;
X ior.io_Offset = (long)chan;
X ior.io_Message.mn_ReplyPort = (PORT *)chan;
X ior.io_Data = (APTR)buf;
X ior.io_Length = bytes;
X PutMsg(chan->dnetport, (MSG *)&ior);
X WaitMsg(&ior);
X if (ior.io_Error)
X error = -1;
X }
X FixSignal(chan);
X return(error);
X}
X
END_OF_FILE
if test 1177 -ne `wc -c <'amiga/lib/dwrite.c'`; then
echo shar: \"'amiga/lib/dwrite.c'\" unpacked with wrong size!
fi
# end of 'amiga/lib/dwrite.c'
fi
if test -f 'amiga/s/dnet.config' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/s/dnet.config'\"
else
echo shar: Extracting \"'amiga/s/dnet.config'\" \(1138 characters\)
sed "s/^X//" >'amiga/s/dnet.config' <<'END_OF_FILE'
X
XLOGF ram:dnet.log
X
X# Commands to set the baud rate, determined by messages that occur
X# before carrier detect. Only scanned if -a option used
X
XAUTA 19200 "CONNECT"
XAUTA 19200 "CONNECT 300"
XAUTA 19200 "CONNECT 1200"
XAUTA 19200 "CONNECT 2400"
XAUTA 19200 "CONNECT 9600"
XAUTA 19200 "CONNECT 19200"
X
X# Commands to Reset the Modem. Only scanned if -a option used
X
XRESM AT
XRESM AT
XRESM ATS0=2
XDISM +++
X
X# Auto-Reset enviroment variable security level to this (DNET_LEVEL)
X#
X# The default is ENVO. The -a option for DNET selects ENVA, -X selects
X# ENVM. Note that the default assumes a hostile enviroment.
X#
X# ENVA -auto answer (-a) option enviroment
X# ENVO -originate (you are dialing up somebody else) option enviroment
X# ENVM -manual (no -a) option enviroment
X#
X# LEVEL overall access rights
X# READ basic access rights for reading files from this machine
X# WRITE basic access rights for writing files to this machine
X
XENVA DNET_LEVEL 0
XENVA DNET_READ 0
XENVA DNET_WRITE 0
X
XENVO DNET_LEVEL 1
XENVO DNET_READ 1
XENVO DNET_WRITE 1
X
XENVM DNET_LEVEL 9
XENVM DNET_READ 9
XENVM DNET_WRITE 9
X
END_OF_FILE
if test 1138 -ne `wc -c <'amiga/s/dnet.config'`; then
echo shar: \"'amiga/s/dnet.config'\" unpacked with wrong size!
fi
# end of 'amiga/s/dnet.config'
fi
if test -f 'amiga/server/scli.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/scli.c'\"
else
echo shar: Extracting \"'amiga/server/scli.c'\" \(2834 characters\)
sed "s/^X//" >'amiga/server/scli.c' <<'END_OF_FILE'
X
X/*
X * SCLI.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * SHELL SERVER. THIS REQUIRES MY PIPE DEVICE TO WORK!!!!!!!!!!
X *
X * Port #8196
X *
X * Only one connection accepted at a time in this baby.
X * HUGE CLUDGE!!!
X *
X * DNET_LEVEL must be 9 or higher.
X */
X
X#include "defs.h"
X
Xchar Buf[4096];
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
X#ifdef LATTICE
X_main(str)
X#else
X_main(len,str)
X#endif
Xchar *str;
X{
X struct MsgPort *port;
X PROC *proc = (PROC *)FindTask(NULL);
X void *chan;
X long mask, rmask;
X long namei = (long)proc;
X APTR oldwptr;
X /*short mycis = 0, mycos = 0;*/
X
X onbreak(brk);
X
X if (strncmp(str, "__dnet", 6) != 0) {
X Version("SCli", VERSION, SCLI_VERSION);
X _exit(0);
X }
X
X port = DListen(PORT_AMIGASHELL);
X WaitPort(&proc->pr_MsgPort);
X ReplyMsg(GetMsg(&proc->pr_MsgPort));
X if (!port)
X _exit(1);
X mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
X oldwptr = proc->pr_WindowPtr;
X proc->pr_WindowPtr = (APTR)-1;
X
X /* REMOVED
X proc->pr_ConsoleTask = DeviceProc("dpipe:");
X if (!proc->pr_CIS) {
X mycis = 1;
X proc->pr_CIS = Open("nil:", 1006);
X }
X if (!proc->pr_COS) {
X mycos = 1;
X proc->pr_COS = Open("nil:", 1006);
X }
X */
X for (;;) {
X rmask = Wait(mask);
X if (rmask & SIGBREAKF_CTRL_C)
X break;
X if (chan = DAccept(port)) {
X long fh;
X long mask;
X long fhmask, smask;
X short sig;
X char pname[16];
X char buf[64];
X
X if (GetEnvVal(DNET_LEVEL) < 9) {
X DWrite(chan, "env:DNET_LEVEL must be >= 9\n", 18);
X DClose(chan);
X continue;
X }
X
X sprintf(pname, "%08lx", namei++);
X sprintf(buf, "newshell <nil: >nil: dpipe:%s/St FROM s:remote-startup", pname);
X DExec(chan, buf);
X sig = AllocSignal(-1);
X fhmask = 1 << sig;
X smask = 1 << ((struct MsgPort *)chan)->mp_SigBit;
X sprintf(buf, "dpipe:%s/Mctns%ld", pname, sig);
X fh = (long)Open(buf, 1006);
X if (fh) {
X char notdone = 1;
X DWrite(chan, "Amiga CLI running\n", 20);
X while (notdone) {
X char buf[256];
X int n;
X mask = Wait(fhmask | smask | SIGBREAKF_CTRL_C);
X while ((n = Read(fh, buf, 256)) > 0) {
X DWrite(chan, buf, n);
X }
X if (n < 0)
X notdone = 0;
X while ((n = DNRead(chan, buf, 256)) > 0) {
X /* REMOVED
X DWrite(chan, buf, n);
X */
X Write(fh, buf, n);
X }
X if (n == -2) {
X short pv;
X char pa;
X DGetIoctl(chan, &pv, &pa);
X } else if (n < 0)
X notdone = 0;
X }
X Write(fh, "ENDCLI\n", 7);
X Write(fh, "ENDCLI\n", 7);
X Close(fh);
X }
X DClose(chan);
X FreeSignal(sig);
X puts("DONE");
X }
X }
X proc->pr_WindowPtr = oldwptr;
X
X /* REMOVED
X if (mycos) {
X Close(proc->pr_COS);
X proc->pr_COS = NULL;
X }
X if (mycis) {
X Close(proc->pr_CIS);
X proc->pr_CIS = NULL;
X }
X */
X DUnListen(port);
X}
X
X
X
END_OF_FILE
if test 2834 -ne `wc -c <'amiga/server/scli.c'`; then
echo shar: \"'amiga/server/scli.c'\" unpacked with wrong size!
fi
# end of 'amiga/server/scli.c'
fi
if test -f 'amiga/server/snfs.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/snfs.h'\"
else
echo shar: Extracting \"'amiga/server/snfs.h'\" \(1617 characters\)
sed "s/^X//" >'amiga/server/snfs.h' <<'END_OF_FILE'
X
X#define ulong unsigned long
X#define ubyte unsigned char
X#define uword unsigned short
X
Xtypedef struct {
X long ds_Days;
X long ds_Minute;
X long ds_Tick;
X} STAMP;
X
Xtypedef struct {
X long DirHandle; /* relative to directory (0=root) */
X uword Modes; /* open modes */
X} OpOpen;
X
Xtypedef struct {
X long Handle;
X ulong Prot;
X long Type;
X long Size;
X STAMP Date;
X} RtOpen;
X
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpRead;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtRead;
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpWrite;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtWrite;
X
Xtypedef struct {
X long Handle;
X} OpClose;
X
Xtypedef struct {
X long Handle;
X long Offset;
X long How;
X} OpSeek;
X
Xtypedef struct {
X long OldOffset;
X long NewOffset; /* -1 = error */
X} RtSeek;
X
Xtypedef struct {
X long Handle;
X} OpParent;
X
Xtypedef RtOpen RtParent;
X
Xtypedef struct {
X long DirHandle;
X} OpDelete;
X
Xtypedef struct {
X long Error;
X} RtDelete;
X
Xtypedef OpDelete OpCreateDir;
Xtypedef RtParent RtCreateDir;
X
Xtypedef struct {
X long Handle;
X long Index;
X} OpNextDir;
X
Xtypedef RtOpen RtNextDir;
X
Xtypedef struct {
X long Handle;
X} OpDup;
X
Xtypedef RtOpen RtDup;
X
Xtypedef struct {
X long DirHandle1;
X long DirHandle2;
X} OpRename;
X
Xtypedef struct {
X long Error;
X} RtRename;
X
END_OF_FILE
if test 1617 -ne `wc -c <'amiga/server/snfs.h'`; then
echo shar: \"'amiga/server/snfs.h'\" unpacked with wrong size!
fi
# end of 'amiga/server/snfs.h'
fi
if test -f 'amiga/server/spasswd.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/spasswd.c'\"
else
echo shar: Extracting \"'amiga/server/spasswd.c'\" \(3336 characters\)
sed "s/^X//" >'amiga/server/spasswd.c' <<'END_OF_FILE'
X
X/*
X * SPASSWD.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * PASSWORD SERVER
X *
X * user-password entry. USER entries in s:dnet.config are scanned for
X * a match and the various dnet enviroment variables are set accordingly.
X */
X
X#include "defs.h"
X
Xint do_password ARGS((void *));
Xvoid DPuts ARGS((void *, char *));
Xint DGetLine ARGS((void *, char *, short));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
X#ifdef LATTICE
X_main(str)
X#else
X_main(len,str)
X#endif
Xchar *str;
X{
X struct MsgPort *port;
X PROC *myproc = (PROC *)FindTask(NULL);
X void *chan;
X long mask, rmask;
X short res;
X
X onbreak(brk);
X
X if (strncmp(str, "__dnet", 6) != 0) {
X Version("SPasswd", VERSION, SPASSWD_VERSION);
X _exit(0);
X }
X
X port = DListen(PORT_PASSWD);
X WaitPort(&myproc->pr_MsgPort);
X ReplyMsg(GetMsg(&myproc->pr_MsgPort));
X
X mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
X for (;;) {
X rmask = Wait(mask);
X if (rmask & SIGBREAKF_CTRL_C)
X break;
X while (chan = DAccept(port)) {
X res = do_password(chan);
X Delay(10L); /* prevent name scan */
X if (res)
X DPuts(chan, "user-password accepted\n");
X else
X DPuts(chan, "user-password failed\n");
X Delay(50L); /* prevent name scan */
X DClose(chan);
X }
X }
X DUnListen(port);
X}
X
Xint
Xdo_password(chan)
Xvoid *chan;
X{
X static char user[64];
X static char pass[64];
X static char buf[128];
X static char suser[64];
X static char spass[64];
X short res;
X long fh;
X short i, n;
X int s_level, s_read, s_write;
X
X DPuts(chan, "User Name: ");
X res = DGetLine(chan, user, 64);
X if (res < 0)
X return(0);
X DIoctl(chan, CIO_MODE, 0, 0);
X DPuts(chan, "Password : ");
X res = DGetLine(chan, pass, 64);
X DIoctl(chan, CIO_MODE, 7, 0);
X if (res < 0)
X return(0);
X
X /*
X * search for USER entry in s:dnet.config
X */
X
X fh = Open("s:dnet.config", 1005);
X if (fh == NULL) {
X DPuts(chan, "s:dnet.config does not exist\n");
X return(0);
X }
X while ((n = Read(fh, buf, 256)) > 0) {
X for (i = 0; i < n - 1; ++i) {
X if (buf[i] == '\n')
X break;
X }
X buf[i] = 0;
X Seek(fh, (i + 1) - n, 0);
X if (strncmp(buf, "USER", 4) == 0) {
X suser[0] = spass[0] = 0;
X s_level = s_read = s_write = 0;
X sscanf(buf + 4, "%s %s %d %d %d", suser, spass, &s_level, &s_read, &s_write);
X if (strcmp(user, suser) == 0 && strcmp(pass, spass) == 0) {
X Close(fh);
X sprintf(buf, "%d", s_level);
X SetDEnv(DNET_LEVEL, buf);
X sprintf(buf, "%d", s_read);
X SetDEnv(DNET_READ, buf);
X sprintf(buf, "%d", s_write);
X SetDEnv(DNET_WRITE, buf);
X return(1);
X }
X }
X }
X Close(fh);
X return(0);
X}
X
Xvoid
XDPuts(chan, str)
Xvoid *chan;
Xchar *str;
X{
X DWrite(chan, str, strlen(str));
X}
X
Xint
XDGetLine(chan, buf, max)
Xvoid *chan;
Xchar *buf;
Xshort max;
X{
X short i = 0;
X short n;
X short notdone = 1;
X char c;
X
X while (notdone) {
X n = DRead(chan, &c, 1);
X if (n == 0) { /* ioctl, ignore */
X short pv;
X char pa;
X DGetIoctl(chan, &pv, &pa);
X continue;
X }
X if (n < 0) {
X buf[i] = 0;
X return(-1);
X }
X switch(c) {
X case 8: /* BS */
X if (i)
X --i;
X break;
X case 10: /* eol */
X case 13:
X notdone = 0;
X break;
X default:
X if (i < max - 1)
X buf[i++] = c;
X break;
X }
X }
X buf[i] = 0;
X return(1);
X}
X
END_OF_FILE
if test 3336 -ne `wc -c <'amiga/server/spasswd.c'`; then
echo shar: \"'amiga/server/spasswd.c'\" unpacked with wrong size!
fi
# end of 'amiga/server/spasswd.c'
fi
if test -f 'amiga/server/sprint.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'amiga/server/sprint.c'\"
else
echo shar: Extracting \"'amiga/server/sprint.c'\" \(1398 characters\)
sed "s/^X//" >'amiga/server/sprint.c' <<'END_OF_FILE'
X
X/*
X * SPRINT.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved.
X *
X * PRINTER SERVER
X *
X * Accepting one connection at a time, dump the file to PRT:
X *
X * DNET_WRITE must be 6 or higher for this function to work.
X */
X
X#include "defs.h"
X
Xvoid printfile ARGS((void *));
X
Xint
Xbrk()
X{
X return(0);
X}
X
Xvoid
X#ifdef LATTICE
X_main(str)
X#else
X_main(len,str)
X#endif
Xchar *str;
X{
X PORT *port;
X PROC *myproc = (PROC *)FindTask(NULL);
X void *chan;
X long mask, rmask;
X
X onbreak(brk);
X
X if (strncmp(str, "__dnet", 6) != 0) {
X Version("SPrint", VERSION, SPRINT_VERSION);
X _exit(0);
X }
X
X port = DListen(PORT_PRINTER);
X WaitPort(&myproc->pr_MsgPort);
X ReplyMsg(GetMsg(&myproc->pr_MsgPort));
X
X mask = SIGBREAKF_CTRL_C|(1 << port->mp_SigBit);
X for (;;) {
X rmask = Wait(mask);
X if (rmask & SIGBREAKF_CTRL_C)
X break;
X while (chan = DAccept(port)) {
X if (GetEnvVal(DNET_WRITE) >= 6) {
X DWrite(chan, "Accepted\n", 9);
X printfile(chan);
X } else {
X DWrite(chan, "Permission Denied\n", 18);
X }
X DClose(chan);
X }
X }
X DUnListen(port);
X}
X
Xvoid
Xprintfile(chan)
Xvoid *chan;
X{
X long n, fh;
X char rc = 0;
X char buf[256];
X
X if (fh = Open("PRT:", 1006)) {
X rc = 1;
X while ((n = DRead(chan, buf, 256)) > 0) {
X if (Write(fh, buf, n) != n) {
X rc = 0;
X break;
X }
X }
X Close(fh);
X }
X DWrite(chan, &rc, 1);
X}
X
END_OF_FILE
if test 1398 -ne `wc -c <'amiga/server/sprint.c'`; then
echo shar: \"'amiga/server/sprint.c'\" unpacked with wrong size!
fi
# end of 'amiga/server/sprint.c'
fi
if test -f 'unix/client/draw.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/client/draw.c'\"
else
echo shar: Extracting \"'unix/client/draw.c'\" \(1617 characters\)
sed "s/^X//" >'unix/client/draw.c' <<'END_OF_FILE'
X
X/*
X * DRAW.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * DRAW [port#]
X *
X * Put terminal into RAW mode and connect to the remote dnet port.
X * used mainly to test DNET. Can also be used open a TERM window on
X * the amiga (via the STERM server), which is the default (port 8195)
X */
X
X
X
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <stdio.h>
X#include <sys/file.h>
X#include <signal.h>
X#include <errno.h>
X#include "../server/servers.h"
X
Xint fd;
Xchar buf[4096];
X
Xmain(ac,av)
Xchar *av[];
X{
X int n;
X extern int handler();
X int port = (av[1]) ? atoi(av[1]) : PORT_AMIGATERM;
X
X puts("DRAW V1.01 11 March 1988 Connecting");
X fd = DOpen(NULL, port, 0, 0);
X if (fd < 0) {
X perror("DOpen");
X exit(1);
X }
X puts("Connected");
X signal(SIGIO, handler);
X ttyraw();
X fcntl(fd, F_SETOWN, getpid());
X fcntl(fd, F_SETFL, FNDELAY|FASYNC);
X fcntl(0, F_SETFL, FNDELAY);
X while ((n = gread(0, buf, sizeof(buf))) > 0) {
X gwrite(fd, buf, n);
X }
X fprintf(stderr, "EOF\n");
X DEof(fd);
X for (;;)
X pause();
X}
X
Xhandler()
X{
X int n;
X char buf[1024];
X
X while ((n = read(fd, buf, sizeof(buf))) > 0)
X write(1, buf, n);
X if (n == 0) {
X write(1, "REMEOF\n", 7);
X ttynormal();
X exit(1);
X }
X}
X
Xstatic struct sgttyb ttym;
X
Xttyraw()
X{
X ioctl (0, TIOCGETP, &ttym);
X ttym.sg_flags |= RAW;
X ttym.sg_flags &= ~CBREAK;
X ttym.sg_flags &= ~ECHO;
X ioctl (0, TIOCSETP, &ttym);
X}
X
Xttynormal()
X{
X ioctl (0, TIOCGETP, &ttym);
X ttym.sg_flags &= ~RAW;
X ttym.sg_flags |= CBREAK;
X ttym.sg_flags |= ECHO;
X ioctl (0, TIOCSETP, &ttym);
X}
X
END_OF_FILE
if test 1617 -ne `wc -c <'unix/client/draw.c'`; then
echo shar: \"'unix/client/draw.c'\" unpacked with wrong size!
fi
# end of 'unix/client/draw.c'
fi
if test -f 'unix/client/dsoc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/client/dsoc.c'\"
else
echo shar: Extracting \"'unix/client/dsoc.c'\" \(1216 characters\)
sed "s/^X//" >'unix/client/dsoc.c' <<'END_OF_FILE'
X
X/*
X * DSOC.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * DSOC [port#]
X *
X * Connect to the specified port# .. Used to connect to a remote CLI
X * (s_shell server on the Amiga, which requires PIPE: to work, port 8196,
X * is the default)
X *
X * Uses standard cooked mode instead of RAW mode.
X */
X
X
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <stdio.h>
X#include <sys/file.h>
X#include <signal.h>
X#include <errno.h>
X#include "../server/servers.h"
X
Xint fd;
Xchar buf[2048];
X
Xmain(ac,av)
Xchar *av[];
X{
X int n;
X extern int handler();
X int port = (av[1]) ? atoi(av[1]) : PORT_AMIGASHELL;
X
X puts("DSOC V1.01 11 March 1988 Connecting");
X fd = DOpen(NULL, port, 0, 0);
X if (fd < 0) {
X perror("DOpen");
X exit(1);
X }
X puts("Connected");
X signal(SIGIO, handler);
X fcntl(fd, F_SETOWN, getpid());
X fcntl(fd, F_SETFL, FNDELAY|FASYNC);
X while ((n = gread(0, buf, sizeof(buf))) > 0) {
X gwrite(fd, buf, n);
X }
X fprintf(stderr, "EOF\n");
X DEof(fd);
X for (;;)
X pause();
X}
X
Xhandler()
X{
X int n;
X char buf[1024];
X
X while ((n = read(fd, buf, sizeof(buf))) > 0)
X write(1, buf, n);
X if (n == 0) {
X write(1, "REMEOF\n", 7);
X exit(1);
X }
X}
X
END_OF_FILE
if test 1216 -ne `wc -c <'unix/client/dsoc.c'`; then
echo shar: \"'unix/client/dsoc.c'\" unpacked with wrong size!
fi
# end of 'unix/client/dsoc.c'
fi
if test -f 'unix/dnet/channel.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/channel.h'\"
else
echo shar: Extracting \"'unix/dnet/channel.h'\" \(2033 characters\)
sed "s/^X//" >'unix/dnet/channel.h' <<'END_OF_FILE'
X
X/*
X * CHANNEL.H
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Channel structures for SCMD_* channel commands.
X *
X * NOTE: These structures may be ONLY 0,2,4, or 6 bytes in size.
X */
X
X#define CSWITCH struct _CSWITCH
X#define COPEN struct _COPEN
X#define CCLOSE struct _CCLOSE
X#define CACKCMD struct _CACKCMD
X#define CEOFCMD struct _CEOFCMD
X#define CIOCTL struct _CIOCTL
X
XCSWITCH { /* SWITCH current data channel */
X ubyte chanh; /* channel to switch to */
X ubyte chanl;
X};
X
XCOPEN { /* OPEN port on channel */
X ubyte chanh; /* try to use this channel */
X ubyte chanl;
X ubyte porth; /* requested port from client */
X ubyte portl;
X ubyte error; /* error return 0=ok */
X char pri; /* chan. priority -127 to 126 */
X};
X
XCCLOSE { /* CLOSE a channel */
X ubyte chanh; /* channel to close */
X ubyte chanl;
X};
X
XCACKCMD { /* Acknowledge an open */
X ubyte chanh; /* channel */
X ubyte chanl;
X ubyte error; /* 0=ok 1=fail 33=retry w/ different channel */
X ubyte filler;
X};
X
XCEOFCMD { /* Send [R/W] EOF */
X ubyte chanh; /* channel to send EOF on */
X ubyte chanl;
X ubyte flags; /* CHANF_ROK/WOK (bits to clear) */
X ubyte filler;
X};
X
XCIOCTL {
X ubyte chanh; /* channel */
X ubyte chanl;
X ubyte cmd; /* ioctl command */
X ubyte valh; /* ioctl value */
X ubyte vall;
X ubyte valaux; /* auxillary field */
X};
X
X#define CIO_SETROWS 1 /* PTY's only */
X#define CIO_SETCOLS 2 /* PTY's only */
X#define CIO_STOP 3 /* any channel, flow control */
X#define CIO_START 4 /* any channel, flow control */
X#define CIO_FLUSH 5 /* any channel, flush pending */
X /* writes down the toilet */
X
X#define CHAN struct _CHAN
X
XCHAN {
X int fd; /* file descriptor for channel */
X uword port; /* port# (used in open sequence) */
X ubyte state; /* state of channel */
X ubyte flags; /* channel flags */
X char pri; /* priority of channel */
X};
X
END_OF_FILE
if test 2033 -ne `wc -c <'unix/dnet/channel.h'`; then
echo shar: \"'unix/dnet/channel.h'\" unpacked with wrong size!
fi
# end of 'unix/dnet/channel.h'
fi
if test -f 'unix/dnet/dataconv.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/dataconv.c'\"
else
echo shar: Extracting \"'unix/dnet/dataconv.c'\" \(2362 characters\)
sed "s/^X//" >'unix/dnet/dataconv.c' <<'END_OF_FILE'
X
X/*
X * DATACONV.C
X *
X * Data Conversion.
X */
X
Xtypedef unsigned char ubyte;
Xtypedef unsigned short uword;
Xtypedef unsigned long ulong;
X
Xextern ubyte DDebug;
X
Xint
XCompress7(s, db, n)
Xubyte *s;
Xubyte *db;
Xuword n; /* actual source bytes */
X{
X ubyte *d = db;
X
X while (n) {
X *d++ = *s++ << 1;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 6;
X *d++ = *s++ << 2;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 5;
X *d++ = *s++ << 3;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 4;
X *d++ = *s++ << 4;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 3;
X *d++ = *s++ << 5;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 2;
X *d++ = *s++ << 6;
X
X if (--n == 0)
X break;
X d[-1] |= *s >> 1;
X *d++ = *s++ << 7;
X
X if (--n == 0)
X break;
X d[-1] |= *s++;
X --n;
X }
X return(d - db);
X}
X
Xvoid
XUnCompress7(s, d, n)
Xubyte *s;
Xubyte *d;
Xuword n; /* actual destination bytes */
X{
X while (n) {
X *d++ = s[0] >> 1;
X
X if (--n == 0)
X break;
X *d++ = ((s[0] << 6) | (s[1] >> 2)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[1] << 5) | (s[2] >> 3)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[2] << 4) | (s[3] >> 4)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[3] << 3) | (s[4] >> 5)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[4] << 2) | (s[5] >> 6)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = ((s[5] << 1) | (s[6] >> 7)) & 0x7F;
X
X if (--n == 0)
X break;
X *d++ = s[6] & 0x7F;
X
X --n;
X s += 7;
X }
X}
X
X
Xint
XExpand6(s, db, n)
Xubyte *s;
Xubyte *db;
Xuword n; /* actual source bytes */
X{
X ubyte *d = db;
X ubyte *sb= s;
X
X while (n) {
X *d++ = 0x40 | (*s >> 2);
X *d++ = 0x40 | ((*s++ & 3) << 4);
X if (--n) {
X d[-1] |= *s >> 4;
X *d++ = 0x40 | ((*s++ & 0x0F) << 2);
X if (--n) {
X d[-1] |= *s >> 6;
X *d++ = 0x40 | (*s++ & 0x3F);
X --n;
X }
X }
X }
X if (DDebug)
X printf("e6: %02x %02x -> %02x %02x %02x\n",
X sb[0], sb[1],
X db[0], db[1], db[2]
X );
X return(d - db);
X}
X
Xvoid
XUnExpand6(s, d, n)
Xubyte *s;
Xubyte *d;
Xuword n; /* actual destination bytes */
X{
X ubyte *sb = s;
X ubyte *db = d;
X
X while (n) {
X *d++ = (s[0] << 2) | ((s[1] & 0x30) >> 4);
X if (--n == 0)
X break;
X *d++ = (s[1] << 4) | ((s[2] & 0x3C) >> 2);
X if (--n == 0)
X break;
X *d++ = (s[2] << 6) | (s[3] & 0x3F);
X --n;
X s += 4;
X }
X if (DDebug)
X printf("d6: %02x %02x <- %02x %02x %02x\n",
X db[0], db[1],
X sb[0], sb[1], sb[2]
X );
X}
X
X
X
END_OF_FILE
if test 2362 -ne `wc -c <'unix/dnet/dataconv.c'`; then
echo shar: \"'unix/dnet/dataconv.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/dataconv.c'
fi
if test -f 'unix/dnet/double.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/double.c'\"
else
echo shar: Extracting \"'unix/dnet/double.c'\" \(1589 characters\)
sed "s/^X//" >'unix/dnet/double.c' <<'END_OF_FILE'
X
X/*
X * DOUBLE
X *
X * DOUBLE DNETDIRA DNETDIRB
X *
X * Run dnet using a pipe (for testing)
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <netinet/in.h>
X#include <netdb.h>
X
Xmain(ac, av, envp)
Xchar *av[];
Xchar **envp;
X{
X int files[2];
X short i;
X char buf[256];
X char cmd[256];
X
X if (ac != 3) {
X puts("double dnetdira dnetdirb");
X exit(1);
X }
X
X for (i = 0; envp[i]; ++i) {
X if (strncmp(envp[i], "DNETDIR=", 8) == 0)
X break;
X }
X if (envp[i] == NULL) {
X puts("must set a dummy DNETDIR enviroment variable");
X exit(1);
X }
X
X
X if (socketpair(AF_UNIX, SOCK_STREAM, 0, files) < 0) {
X perror("socketpair");
X exit(1);
X }
X
X envp[i] = buf;
X if (fork() == 0) {
X int fd = open("d1.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
X if (dup2(files[0], 0) < 0)
X perror("dup2-1");
X dup2(fd, 1);
X dup2(fd, 2);
X if (write(0, "", 0) < 0) {
X perror("write");
X exit(1);
X }
X sprintf(buf, "DNETDIR=%s", av[1]);
X execlp("dnet", "dnet", "debug", NULL);
X perror("exec");
X exit(1);
X }
X if (fork() == 0) {
X int fd = open("d2.log", O_WRONLY | O_CREAT | O_TRUNC, 0666);
X if (dup2(files[1], 0) < 0)
X perror("dup2-1");
X dup2(fd, 1);
X dup2(fd, 2);
X close(files[0]);
X close(files[1]);
X if (write(0, "", 0) < 0) {
X perror("write");
X exit(1);
X }
X sprintf(buf, "DNETDIR=%s", av[2]);
X execlp("dnet", "dnet", "debug", NULL);
X perror("exec");
X exit(1);
X }
X close(files[0]);
X close(files[1]);
X {
X int pid;
X while ((pid = wait(0)) > 0)
X printf("pid %d exit\n", pid);
X }
X}
X
END_OF_FILE
if test 1589 -ne `wc -c <'unix/dnet/double.c'`; then
echo shar: \"'unix/dnet/double.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/double.c'
fi
if test -f 'unix/dnet/files.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/files.c'\"
else
echo shar: Extracting \"'unix/dnet/files.c'\" \(3476 characters\)
sed "s/^X//" >'unix/dnet/files.c' <<'END_OF_FILE'
X
X/*
X * FILES.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * handles actions on a per file descriptor basis, including accepting
X * new connections, closing old connections, and transfering data
X * between connections.
X */
X
X#include "dnet.h"
X
Xextern void do_localopen(), do_connect(), do_open1(), do_openwait(), do_open();
X
X/*
X * new connection over master port... open request. read two byte port
X * number, allocate a channel, and send off to the remote
X */
X
Xvoid
Xdo_localopen(n, fd)
X{
X struct sockaddr sa;
X int addrlen = sizeof(sa);
X int s;
X uword chan;
X
X if (DDebug)
X fprintf(stderr, "DO_LOCALOPEN %ld %ld\n", n, fd);
X while ((s = accept(fd, &sa, &addrlen)) >= 0) {
X chan = alloc_channel();
X fcntl(s, F_SETFL, FNDELAY);
X if (DDebug)
X fprintf(stderr, " ACCEPT: %ld on channel %ld ", s, chan);
X if (chan == 0xFFFF) {
X ubyte error = 1;
X gwrite(s, &error, 1);
X close(s);
X if (DDebug)
X fprintf(stderr, "(no channels)\n");
X continue;
X }
X Fdstate[s] = do_open1;
X FdChan[s] = chan;
X FD_SET(s, &Fdread);
X FD_SET(s, &Fdexcept);
X Chan[chan].fd = s;
X Chan[chan].state = CHAN_LOPEN;
X if (DDebug)
X fprintf(stderr, "(State = CHAN_LOPEN)\n");
X }
X}
X
Xvoid
Xdo_open1(n_notused, fd)
X{
X uword port;
X char trxpri[2];
X uword chan = FdChan[fd];
X COPEN co;
X int n;
X
X if (DDebug)
X fprintf(stderr, "DO_OPEN %ld %ld on channel %ld ", n, fd, chan);
X for (;;) {
X n = read(fd, &port, 2);
X if (n < 0) {
X if (errno == EINTR)
X continue;
X if (errno == EWOULDBLOCK)
X return;
X }
X read(fd, trxpri, 2);
X if (n != 2)
X dneterror("do_open1: unable to read 2 bytes");
X break;
X }
X if (DDebug)
X fprintf(stderr, "Port %ld\n", port);
X co.chanh = chan >> 8;
X co.chanl = chan;
X co.porth = port >> 8;
X co.portl = port;
X co.error = 0;
X co.pri = trxpri[1];
X Chan[chan].port = port;
X Chan[chan].pri = 126;
X WriteStream(SCMD_OPEN, &co, sizeof(co), chan);
X Chan[chan].pri = trxpri[0];
X Fdstate[fd] = do_openwait;
X if (DDebug)
X fprintf(stderr, " Newstate = openwait\n");
X}
X
Xvoid
Xdo_openwait(n, fd)
X{
X ubyte buf[32];
X if (DDebug)
X fprintf(stderr, "************ ERROR DO_OPENWAIT %ld %ld\n", n, fd);
X n = read(fd, buf, 32);
X if (DDebug) {
X fprintf(stderr, " OPENWAIT, READ %ld bytes\n", n);
X if (n < 0)
X perror("openwait:read");
X }
X}
X
Xvoid
Xdo_open(nn, fd)
X{
X extern void nop();
X char buf[256];
X uword chan = FdChan[fd];
X int n;
X
X n = read(fd, buf, sizeof(buf));
X if (DDebug) {
X fprintf(stderr, "DO_OPEN %ld %ld, RECEIVE DATA on chan %ld (%ld by)\n",
X nn, fd, chan, n);
X fprintf(stderr, " fd, chanfd %ld %ld\n", fd, Chan[chan].fd);
X if (n < 0)
X perror("open:read");
X }
X if (n == 0 || nn == 2) { /* application closed / exception cond */
X CCLOSE cc;
X
X if (DDebug)
X fprintf(stderr, " DO_OPEN: REMOTE EOF, channel %d\n", chan);
X
X cc.chanh = chan >> 8;
X cc.chanl = chan;
X WriteStream(SCMD_CLOSE, &cc, sizeof(CCLOSE), chan);
X Chan[chan].state = CHAN_CLOSE;
X Chan[chan].flags |= CHANF_LCLOSE;
X if (Chan[chan].flags & CHANF_RCLOSE) {
X ;
X /* should never happen
X int fd = Chan[chan].fd;
X Chan[chan].state = CHAN_FREE;
X Chan[chan].fd = -1;
X Fdstate[fd] = nop;
X FD_CLR(fd, &Fdread);
X FD_CLR(fd, &Fdexcept);
X close(fd);
X */
X } else {
X FD_CLR(fd, &Fdread);
X FD_CLR(fd, &Fdexcept);
X }
X }
X if (n > 0) {
X WriteStream(SCMD_DATA, buf, n, chan);
X }
X}
X
END_OF_FILE
if test 3476 -ne `wc -c <'unix/dnet/files.c'`; then
echo shar: \"'unix/dnet/files.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/files.c'
fi
if test -f 'unix/dnet/net.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/dnet/net.c'\"
else
echo shar: Extracting \"'unix/dnet/net.c'\" \(1968 characters\)
sed "s/^X//" >'unix/dnet/net.c' <<'END_OF_FILE'
X
X/*
X * NET.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * NetWork raw device interface. Replace with whatever interface you
X * want.
X */
X
X#include "dnet.h"
X#include <sys/stat.h>
X
XRcvInt()
X{
X int n = read(0, RcvBuf + RcvData, RCVBUF - RcvData);
X int i;
X extern int errno;
X
X errno = 0;
X if (n >= 0)
X RcvData += n;
X if (n <= 0) /* disallow infinite fast-timeout select loops */
X RExpect = 0;
X if (DDebug)
X printf("read(%d,%d)\n", n, errno);
X}
X
Xstatic struct sgttyb ttym;
Xstatic struct stat Stat;
X
XNetOpen()
X{
X int async = 1;
X
X fstat(0, &Stat);
X fchmod(0, 0600);
X /*
X signal(SIGIO, RcvInt);
X */
X ioctl (0, TIOCGETP, &ttym);
X if (Mode7) {
X ttym.sg_flags &= ~RAW;
X ttym.sg_flags |= CBREAK;
X } else {
X ttym.sg_flags |= RAW;
X ttym.sg_flags &= ~CBREAK;
X }
X ttym.sg_flags &= ~ECHO;
X ioctl (0, TIOCSETP, &ttym);
X /*
X ioctl (0, FIOASYNC, &async);
X */
X ioctl (0, FIONBIO, &async);
X}
X
XNetClose()
X{
X int async = 0;
X
X fchmod(0, Stat.st_mode);
X ioctl (0, FIONBIO, &async);
X /*
X ioctl (0, FIOASYNC, &async);
X */
X ioctl (0, TIOCGETP, &ttym);
X ttym.sg_flags &= ~RAW;
X ttym.sg_flags |= ECHO;
X ioctl (0, TIOCSETP, &ttym);
X}
X
XNetWrite(buf, bytes)
Xubyte *buf;
X{
X if (DDebug)
X fprintf(stderr, "NETWRITE %08lx %ld\n", buf, bytes);
X gwrite(0, buf, bytes);
X}
X
Xgwrite(fd, buf, bytes)
Xregister char *buf;
Xregister long bytes;
X{
X register long n;
X while (bytes) {
X n = write(fd, buf, bytes);
X if (n > 0) {
X bytes -= n;
X buf += n;
X continue;
X }
X if (errno == EINTR)
X continue;
X if (errno == EWOULDBLOCK) {
X fd_set fd_wr;
X fd_set fd_ex;
X FD_ZERO(&fd_wr);
X FD_ZERO(&fd_ex);
X FD_SET(fd, &fd_wr);
X FD_SET(fd, &fd_ex);
X if (select(fd+1, NULL, &fd_wr, &fd_ex, NULL) < 0) {
X perror("select");
X }
X continue;
X }
X if (errno == EPIPE)
X return;
X dneterror("gwrite");
X }
X}
X
END_OF_FILE
if test 1968 -ne `wc -c <'unix/dnet/net.c'`; then
echo shar: \"'unix/dnet/net.c'\" unpacked with wrong size!
fi
# end of 'unix/dnet/net.c'
fi
if test -f 'unix/server/scopy.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/server/scopy.c'\"
else
echo shar: Extracting \"'unix/server/scopy.c'\" \(3081 characters\)
sed "s/^X//" >'unix/server/scopy.c' <<'END_OF_FILE'
X
X/*
X * SCOPY.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Remote file copy server (putfiles is the client program)
X */
X
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sys/wait.h>
X#include <sys/time.h>
X#include <sys/file.h>
X#include <sys/resource.h>
X#include <stdio.h>
X#include <errno.h>
X#include <signal.h>
X
X#include "servers.h"
X#include "../lib/dnetlib.h"
X
Xchar Buf[4096];
X
Xchandler()
X{
X union wait stat;
X struct rusage rus;
X while (wait3(&stat, WNOHANG, &rus) > 0);
X}
X
Xmain(ac,av)
Xchar *av[];
X{
X long chann = DListen(PORT_FILECOPY);
X int fd;
X int n;
X char buf[256];
X extern int errno;
X
X elog(EDEBUG, "SCOPY START", 0);
X if (av[1])
X chdir(av[1]);
X signal(SIGCHLD, chandler);
X signal(SIGPIPE, SIG_IGN);
X for (;;) {
X fd = DAccept(chann);
X if (fd < 0) {
X if (errno == EINTR)
X continue;
X break;
X }
X elog(EDEBUG, "SCOPY CONNECT", 0);
X if (fork() == NULL) {
X putdir(fd, ".");
X _exit(1);
X }
X close(fd);
X }
X perror("SCOPY");
X}
X
Xputdir(chan, dirname)
Xchar *dirname;
X{
X struct stat stat;
X char olddir[256];
X char co, nl, name[128];
X long len;
X int ret = -1;
X
X getwd(olddir);
X if (lstat(dirname, &stat) >= 0 && !(stat.st_mode & S_IFDIR)) {
X char rc = 'N';
X gwrite(chan, &rc, 1);
X elog(EWARN, "SCOPY: Unable to cd to dir '%s'", dirname);
X return(1);
X }
X if (chdir(dirname) < 0) {
X if (mkdir(dirname, 0777) < 0 || chdir(dirname) < 0) {
X char rc = 'N';
X elog(EWARN, "SCOPY: Unable to create directory '%s'", dirname);
X gwrite(chan, &rc, 1);
X return(1);
X }
X }
X co = 'Y';
X gwrite(chan, &co, 1);
X while (ggread(chan, &co, 1) == 1) {
X if (ggread(chan, &nl, 1) != 1 || ggread(chan, name, nl) != nl)
X break;
X if (ggread(chan, &len, 4) != 4)
X break;
X len = ntohl68(len);
X switch(co) {
X case 'C':
X co = 'Y';
X if (chdir(name) < 0) {
X if (mkdir(name, 0777) < 0 || chdir(name) < 0) {
X co = 'N';
X elog(EWARN, "SCOPY: Unable to create directory '%s'",
X dirname);
X }
X }
X gwrite(chan, &co, 1);
X break;
X case 'W':
X if (putfile(chan, name, len) < 0) {
X ret = -1;
X elog(EWARN, "SCOPY: Failure on file %.*s", len, name);
X goto fail;
X }
X break;
X case 'X':
X if (putdir(chan, name) < 0) {
X ret = -1;
X goto fail;
X }
X break;
X case 'Y':
X ret = 1;
X co = 'Y';
X gwrite(chan, &co, 1);
X goto fail;
X default:
X co = 'N';
X gwrite(chan, &co, 1);
X break;
X }
X }
Xfail:
X chdir(olddir);
X return(ret);
X}
X
Xputfile(chan, name, len)
Xchar *name;
X{
X long fd = open(name, O_WRONLY|O_CREAT|O_TRUNC, 0666);
X long n, r;
X char rc;
X
X if (fd < 0) {
X rc = 'N';
X gwrite(chan, &rc, 1);
X return(0);
X }
X rc = 'Y';
X gwrite(chan, &rc, 1);
X while (len) {
X r = (len > sizeof(Buf)) ? sizeof(Buf) : len;
X n = ggread(chan, Buf, r);
X if (n != r)
X break;
X if (write(fd, Buf, n) != n)
X break;
X len -= n;
X }
X close(fd);
X if (len) {
X unlink(name);
X return(-1);
X }
X rc = 'Y';
X gwrite(chan, &rc, 1);
X return(0);
X}
X
END_OF_FILE
if test 3081 -ne `wc -c <'unix/server/scopy.c'`; then
echo shar: \"'unix/server/scopy.c'\" unpacked with wrong size!
fi
# end of 'unix/server/scopy.c'
fi
if test -f 'unix/server/sloadav.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/server/sloadav.c'\"
else
echo shar: Extracting \"'unix/server/sloadav.c'\" \(1227 characters\)
sed "s/^X//" >'unix/server/sloadav.c' <<'END_OF_FILE'
X
X/*
X * SLOADAV.C
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Reports the load average every 5 minutes or until the connection
X * is closed.
X */
X
X#include <stdio.h>
X#include <sys/wait.h>
X#include <sys/time.h>
X#include <sys/resource.h>
X#include <errno.h>
X#include <signal.h>
X
X#include "servers.h"
X
Xchandler()
X{
X union wait stat;
X struct rusage rus;
X while (wait3(&stat, WNOHANG, &rus) > 0);
X}
X
Xmain(ac,av)
Xchar *av[];
X{
X long chann = DListen(PORT_LOADAV);
X int fd;
X int n;
X char buf[256];
X extern int errno;
X
X if (av[1])
X chdir(av[1]);
X signal(SIGCHLD, chandler);
X signal(SIGPIPE, SIG_IGN);
X for (;;) {
X fd = DAccept(chann);
X if (fd < 0) {
X if (errno == EINTR)
X continue;
X break;
X }
X if (fork() == NULL) {
X do_loadav(fd);
X close(fd);
X _exit(1);
X }
X close(fd);
X }
X perror("SLOADAV");
X}
X
Xdo_loadav(fd)
X{
X char dummy;
X char buf[256];
X FILE *fi;
X
X while (ggread(fd, &dummy, 1) == 1) {
X fi = popen("uptime", "r");
X if (fi == NULL)
X break;
X if (fgets(buf, 256, fi)) {
X dummy = strlen(buf);
X buf[dummy-1] = 0;
X gwrite(fd, &dummy, 1);
X gwrite(fd, buf, dummy);
X }
X if (ferror(fi))
X break;
X pclose(fi);
X }
X}
X
END_OF_FILE
if test 1227 -ne `wc -c <'unix/server/sloadav.c'`; then
echo shar: \"'unix/server/sloadav.c'\" unpacked with wrong size!
fi
# end of 'unix/server/sloadav.c'
fi
if test -f 'unix/server/snfs.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/server/snfs.h'\"
else
echo shar: Extracting \"'unix/server/snfs.h'\" \(1617 characters\)
sed "s/^X//" >'unix/server/snfs.h' <<'END_OF_FILE'
X
X#define ulong unsigned long
X#define ubyte unsigned char
X#define uword unsigned short
X
Xtypedef struct {
X long ds_Days;
X long ds_Minute;
X long ds_Tick;
X} STAMP;
X
Xtypedef struct {
X long DirHandle; /* relative to directory (0=root) */
X uword Modes; /* open modes */
X} OpOpen;
X
Xtypedef struct {
X long Handle;
X ulong Prot;
X long Type;
X long Size;
X STAMP Date;
X} RtOpen;
X
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpRead;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtRead;
X
Xtypedef struct {
X long Handle; /* file handle to read from */
X long Bytes; /* # of bytes to read */
X} OpWrite;
X
Xtypedef struct {
X long Bytes; /* < 0 == error */
X} RtWrite;
X
Xtypedef struct {
X long Handle;
X} OpClose;
X
Xtypedef struct {
X long Handle;
X long Offset;
X long How;
X} OpSeek;
X
Xtypedef struct {
X long OldOffset;
X long NewOffset; /* -1 = error */
X} RtSeek;
X
Xtypedef struct {
X long Handle;
X} OpParent;
X
Xtypedef RtOpen RtParent;
X
Xtypedef struct {
X long DirHandle;
X} OpDelete;
X
Xtypedef struct {
X long Error;
X} RtDelete;
X
Xtypedef OpDelete OpCreateDir;
Xtypedef RtParent RtCreateDir;
X
Xtypedef struct {
X long Handle;
X long Index;
X} OpNextDir;
X
Xtypedef RtOpen RtNextDir;
X
Xtypedef struct {
X long Handle;
X} OpDup;
X
Xtypedef RtOpen RtDup;
X
Xtypedef struct {
X long DirHandle1;
X long DirHandle2;
X} OpRename;
X
Xtypedef struct {
X long Error;
X} RtRename;
X
END_OF_FILE
if test 1617 -ne `wc -c <'unix/server/snfs.h'`; then
echo shar: \"'unix/server/snfs.h'\" unpacked with wrong size!
fi
# end of 'unix/server/snfs.h'
fi
if test -f 'unix/server/sshell.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'unix/server/sshell.c'\"
else
echo shar: Extracting \"'unix/server/sshell.c'\" \(1313 characters\)
sed "s/^X//" >'unix/server/sshell.c' <<'END_OF_FILE'
X
X/*
X * S_SHELL.C OBSOLETE OBSOLETE OBSOLETE
X *
X * DNET (c)Copyright 1988, Matthew Dillon, All Rights Reserved
X *
X * Connect a csh to a pseudo terminal pair... PORT_ALPHATERM
X * NOTE!! PORT_IALPHATERM (a pseudo-terminal csh) is also available
X * through the FTERM client program on the Amiga side, and much faster
X * since the server for PORT_IALPHATERM is DNET itself (one less process
X * to go through).
X *
X * -doesn't handle SIGWINCH
X * -doesn't handle flow control ... don't cat any long files!
X */
X
X#include <stdio.h>
X#include <sys/wait.h>
X#include <sys/time.h>
X#include <sys/resource.h>
X#include <errno.h>
X#include <signal.h>
X
X#include "servers.h"
X
Xchandler()
X{
X union wait stat;
X struct rusage rus;
X while (wait3(&stat, WNOHANG, &rus) > 0);
X}
X
Xmain(ac,av)
Xchar *av[];
X{
X long chann = DListen(PORT_ALPHATERM);
X int fd;
X int n;
X char buf[256];
X extern int errno;
X
X if (av[1])
X chdir(av[1]);
X signal(SIGCHLD, chandler);
X signal(SIGPIPE, SIG_IGN);
X for (;;) {
X fd = DAccept(chann);
X if (fd < 0) {
X if (errno == EINTR)
X continue;
X break;
X }
X if (fork() == NULL) {
X dup2(fd, 0);
X dup2(fd, 1);
X dup2(fd, 2);
X close(fd);
X execl("/usr/ucb/rlogin", "rlogin", "localhost", NULL);
X exit(1);
X }
X close(fd);
X }
X perror("SSHELL");
X}
X
END_OF_FILE
if test 1313 -ne `wc -c <'unix/server/sshell.c'`; then
echo shar: \"'unix/server/sshell.c'\" unpacked with wrong size!
fi
# end of 'unix/server/sshell.c'
fi
echo shar: End of archive 2 \(of 8\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 8 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
Mail comments to the moderator at <amiga-request@cs.odu.edu>.
Post requests for sources, and general discussion to comp.sys.amiga.